I've recently learn that it's possible to @import
.js
files in a manner similar to css
files (see S.O. Q/A here).
Now the task of knowing when and when not to @import
.
It seems answer's a matter of the pros/cons between number of page requests and size of the requests. Should only large .js
files be added to pages conditionally and smaller ones globally imported? If so, what is a good general file-size cut-off limit?
An example:
Should a script like Fit Vids .js (which unminified is 2.698 kb
) be included via @import
for a site that only has videos on some pages? Or should it be conditionally added (via manual methods or dynamic logic - is there any such script to conditionally load .js
?) for only pages with videos?