Best practice for including css and javascript files [closed] - javascript

Closed. This question is opinion-based. It is not currently accepting answers.
Want to improve this question? Update the question so it can be answered with facts and citations by editing this post.
Closed 9 years ago.
Improve this question
I've always wondered about including javascript libraries and a mess of stylesheets in pages that don't ever use them. It got me wondering if maybe performance would improve, however slight, if I were to include these files on an as needed basis. Is there a best practice to go by on this? Some of these javascript libraries are very large and if they're not needed, it would seem to me that they shouldn't be included.
I'd like to hear the thoughts from others on this.

I think you are talking about Asynchronous Module Definitions (AMD).
One of the more popular implementations of this is Require.js. Check it out.

Related

Is naming minimized files with "min" necessary? [closed]

Closed. This question is opinion-based. It is not currently accepting answers.
Want to improve this question? Update the question so it can be answered with facts and citations by editing this post.
Closed 2 years ago.
Improve this question
As you know, the minimized version of files that include CSS, JS and etc. are also named as "xxx.min.js". For example "bootstrap.min.js".
Is it in any way significant or necessary to include ".min." in a minimized file name in terms of SEO or semantics? Or is it just a convention to be followed?
It is just a convention.
It stops you, the developer, from getting your production and development files muddled.
If you provide your code as a download for other people to use, it makes it clear which version is which.

javascript/Jquery code organisation [closed]

Closed. This question is opinion-based. It is not currently accepting answers.
Want to improve this question? Update the question so it can be answered with facts and citations by editing this post.
Closed 7 years ago.
Improve this question
I'm creating a php app where almost all requests are in ajax and some Jquery effects, so some of my pages are up to 2000 lines of code, all my jquery in one big $document.ready{}, is it normal? should I be ashamed of showing this code to other developers? or is there a better way of organasing Jquery code ?
Like how many others have said, if it's maintainable and easy to read then it shouldn't be much of an issue. However, in my experiences, code that is organized into separate logical modules were MUCH easier to read and maintain than one long document.
With that being said, the typical workflow these days with tools such as browserify would be to refactor and separate the code such that each file executes a specific task for development purposes and when it is time to deploy to production, one would use a build tool to group/minify and optimize for the browser.

Optimizing pages from side of javascript [closed]

Closed. This question is opinion-based. It is not currently accepting answers.
Want to improve this question? Update the question so it can be answered with facts and citations by editing this post.
Closed 8 years ago.
Improve this question
I need to know about two things. I was looking on google but I could not found any good.
First thing is: Location of the scripts in the structure of documents.
Can anyone explain to me what's going on? How it works to optimize pages and where you should put the scripts?
Second thing is: Packing and compressing js code.
I find some packers in google like this: http://dean.edwards.name/packer/ but how its work? All writen scripts should pack?
Please for an explanation or some link to article.
Concerning your first point, one answer to look at would be this one:
https://stackoverflow.com/a/24070373/1145461
Concerning the 2nd point, hopefully this link will help:
http://en.wikipedia.org/wiki/Minification_(programming)

Javascript- Good practice for beginners? [closed]

Closed. This question is opinion-based. It is not currently accepting answers.
Want to improve this question? Update the question so it can be answered with facts and citations by editing this post.
Closed 9 years ago.
Improve this question
How should a beginner JavaScript programmer practice knowing they cannot code any program due to limited knowledge.
Is there any place where I can find some exercises to practice as I keep forgetting because I never practice what I learned..
There are many place to learn, one that I found very useful was codecademy which has set tutorials. I find I learn best when I have an objective that I am working towards, which codecademy provides.
Perhaps you could take a look here and find a few projects that sound interesting? The only way to get better is to practice.

JavaScript Minification & Concatenation Best Practices? [closed]

Closed. This question is opinion-based. It is not currently accepting answers.
Want to improve this question? Update the question so it can be answered with facts and citations by editing this post.
Closed 9 years ago.
Improve this question
If you are building a 10 page site and using uglifyJS to minify and concatenate all the javascript code to a single file, what is the best practice for optimizing code globally across the site?
Let's say for arguments sake all pages have shared code and have some unique code. Do you include all the code into the single minified javascript file and include code that won't be used on every page? Or should you create an additional minified javascript file for every page with the unique code?
I know the best choice is probably unique to every site but if there is a general rule of thumb that applies, I am curious to know what the best approach would be.

Categories

Resources