javascript - Does it make a difference how I get the user to load a script into a webpage? -


i know small , maybe not worth taking time consider or change, i'm still interested (also maybe significant bigger files). injecting 1 of several js scripts webpage, based on http parameter: server (php) looks @ parameter's value , loads corresponding script. question is, there, hypothetically, difference between doing this:

<script type="text/javascript" src="<?php echo getscriptlocation($_get["foo"]); ?>"></script> 

and this:

<script type="text/javascript"> <?php echo getscript($_get["foo"]); </script> 

?

that is, there perceived difference client based on whether send them script, or script's location?

if send script location, client makes http requests in background , execute when it's ready. let page load continue , reduces size of page requested.

the requested script can cached client, makes additional request instantaneous.

i prefers pass location. 1 script works fine. if have tons of them, should group scripts in way reduce number of requests, on mobile clients lot of simultaneous requests bad.


Comments

Popular posts from this blog

authentication - Mongodb revoke acccess to connect test database -

r - Update two sets of radiobuttons reactively - shiny -

ios - Realm over CoreData should I use NSFetchedResultController or a Dictionary? -