Keep the Script folder light, clean and organized in my asp.net MVC solution

I usually store my personal javascripts in subfolders under scripts (see screenshot below). This method allows me to keep the Script folder clean, easy, and convenient for the organization. This is my personal point of view. Now I don’t know what to do with all other scripts (jquery, MicrosoftAjax, ...) , and I’m wondering how other people organize the Script folder . I think that I will store them in subfolders, such as the jquery or General folder, or ...

enter image description here

Can you give me your point of view?

+4
source share
3 answers

I recommend the Minify tool, which merges and reduces all your JS files, so you only need one tag <script src="/min/f=mod1.js,mod2.js,mod3.js" type="text/javascript"></script> .

You can store your JS files, but you want to, even outside the root website, and it does not matter, because they will simply be referenced in the PHP associative array in the Minify groupsConfig.php file. I would recommend this specifically for your situation. For instance:

 'js' => array( '//Scripts/Cart/cartScript.js', '//Scripts/tiny_mce/common.js', '//Scripts/weblog.js', // and so on... ) 

Then your script tag will look like this:

 <script src="/min/g=js" type="text/javascript"></script> 

After Minify combines and minimizes your code, it will cache it on your server so that subsequent requests get into the cache file, so PHP will not need to be processed. Of course, the main advantage of this tool is that your users only download one JavaScript file from your server instead of having to open multiple http connections to download multiple files, which is usually the main deterrent.

http://code.google.com/p/minify/

0
source

I put in the js / libs folder, personally I prefer to use lowercase letters. To solve the cdn problem, use this code:

 <script src="http://ajax.googleapis.com/ajax/libs/jquery/1.6.2/jquery.min.js"></script> <script>window.jQuery || document.write('<script src="js/libs/jquery-1.6.2.min.js">\/script>')</script> 
+2
source

I found that for public websites hosting shared javascript libraries on CDN is better for performance. For example, using Microsoft or Google .

If you still want to place them domestically, there really is no difference in subfolders in performance, so it depends on personal preferences. If you find it tidier using the General subfolder or the jQuery and Microsoft subfolder, go with this approach.

0
source

Source: https://habr.com/ru/post/1392764/


All Articles