2

Can we prevent extra loading of CSS and JS files in the pages which includes similar CSS and JS files. For example index.html file have a CSS and JS file and index1.html also have both CSS and JS same files. So if index.html file have loaded in a browser then at the time of loading index1.html no required of loading the CSS and JS pages i.e. can we reuse the previously loaded CSS and JS file in case of loading index2.html file.

All common jquery and related js scripts, images, css should be loaded only once. In other words, the login page load and subsequent pages are loading the common stuff every time. Can there is any way to solve this problem in HTML pages.

Thanks in advance.

2 Answers 2

3

This is already happening... It's a matter of cache. You should set properly your cache expire time.

Sign up to request clarification or add additional context in comments.

5 Comments

Browsers have already their own cache system (Web Cache). However, you can "alterate" it. If you are using .htaccess files just check this: mod_expires.
The point here is the use of the same CSS and JS files, using consistently the same URLs. (You can still use href="foo.js" in one file and href="../foo.js" in another, as long as they evaluate the same absolute URL.) There are ways to affect cacheing, but mostly it is not needed (and doing it wrong way could make things worse).
Without including JS and CSS files in the second page how can i manage those files in cache?
@Banshi you cannot do that, you have to include them also in second page.
@Mihai Is this possible to load common js and css files to be loaded only once rather than loading on every pages.
1

Those files are already using same JS and CSS, most browsers use their own cache system. You just need to include same path to JS and CSS in both files and it should be ok.

You cannot use any javascript or stylesheet if you don't have them included.

4 Comments

Actually all common jquery and related js scripts, images, css should be loaded only once. Is this possible in HTML?
I don't understand, your first phrase is actually an statement and the second is a question? Doesn't make sense
Second pharse is the actual requirement.
no, is not possible, you have to load every resource needed on every page you want to display.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.