0

I have a Composite Component which I insert two times in a page, one for each different "page type" in diferent containers (either wide screen or tablet), with media queries I select which .css file to apply, and in those .css files I select to display:none certain div's. Now, those Composite Components of mine apply the same .js file which has lots of functions that are used by the component... my question is, Does the .js file apply two times despite the fact one div is not displayed and the other is?

Rodrigo Martinez
  • 913
  • 3
  • 13
  • 29

1 Answers1

0

Most browsers will cache JavaScript files so the client will not need to download the file twice. To avoid this I would recommend moving the script reference up to the main page instead of having it in the 2 DIVs. If you place the <script> at the bottom of the page it will not run until the <div> is loaded.

Scott Murphy
  • 448
  • 2
  • 12