Answer the question
In order to leave comments, you need to log in
How to load different sets of libraries on different pages?
There are pages where jquery libraries like colorbox selectbox rado and others are used. The
question is - is it right to drive them all into the assembly together or is there another solution?
Answer the question
In order to leave comments, you need to log in
usually yes, all libraries are loaded together in the head or at the end of the site template.
of course, you can pull them depending on the page, but such code is more difficult to maintain, and the difference in loading speed is usually very small.
It all depends on the engine. For example, if PHP is used, then before sending the page to the browser, you can set a condition like:
$head="<!DOCTYPE html><html><head><meta charset=\"utf-8\">
if(strpos($html,"$(")!==FALSE){ // сочетание $( или jQuery( всегда есть в кодах jQuery
$head.="<script type=\"text/javascript\" src=\"js/jquery-2.1.4.min.js\"></script>";
}
$head.="</head>"; // и так далее
I don't see much point if caching is enabled for js files.
Sooner or later, the visitor will have to load the script on some page of your site, so why not do it the first time they visit any of the pages? All at once, but once.
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question