0

I Have created a flatfile based cms. PHP and jquery mostly. It is very dynamic and easy in use. I have 3 javascript includes for juery and other functions. This is for the main cms files. So that is quite allright.

But i have written multiple plugins/addons for he cms, also jquery and php, guestbook, comments, rating system, album galleries, site search,.... The problem is that each plugin has javascripts included. And i need to include all scripts in the head part of my main cms in order for the plugin to work on the cms. Now all javascripts get loaded every time the page reloads or if u click a link. That gives many http requests wich slows the cms down. About 15 javascrip files are included in the head now

Is here a way i can load only the needed javascript files and not all of them with a function of some kind.

i tried to compress all the javascript into one file, but that gives errors...

I hope my question is clear in my bad english :) thx for any response

3
  • Try require.js. It's a dependency management plugin. Commented Mar 23, 2014 at 10:03
  • js files load only once - latly browser keep them in cache, you can relax Commented Mar 23, 2014 at 10:08
  • indeed but it slows site down, if i can load it simultanious it would be better Commented Mar 23, 2014 at 10:14

2 Answers 2

1

The tool you are looking for is called grunt.

http://gruntjs.com/

You have over 2000 packages for doing many things and one of them in concatenation and minification.

grunt-contrib-cssmin grunt-contrib-uglify grunt-contrib-concat the list goes on an on, but check 'em all here.

https://github.com/gruntjs/grunt-contrib

grunt is a little confusing the first time you see it, but there are heaps of resources for it and also heaps of stackoverflow examples.

Once you go grunt you never go back!

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

Comments

0

I'd think you can merge all javascript files and then minify it. are you using double function names or do you have javascript code outside of functions? maybe that is what is throwing up your errors.

would leave you with only one request to retrieve all your javascript functions , and you would only need to minify / compress one file.

Comments

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.