jquery - What is the best practice for referencing javascript that is specific to a PartialView in asp.net-mvc? -


I have an asp.nset-mvc site and I have a partial view that is present in many different views .

There is also a .js file attached to the functionality used by partial visualization.

I am currently adding that JS file to each parent scene that puts this partial view inside the head section.

Now I am thinking that to keep it easy to remove the reference of the file from every parent's view and insert the context within the body of the partial scene. (Hence it is listed only in one place)

Do anybody see any consequences for this change? Is this a recommended practice with javascript that is leverage by only a special partial view?

I will ask myself some questions:

  1. How big is the JS file is? How big is this?
  2. How often is it used in the average use in your application?

    If this is a large file that has not been used too much, I will include the script inside the file and will not make any deal about it.

    You should remember that JS files are cached, and if the average user enters partial view, he will need to download the script.

    For a good method to deal with script \ styling:

    Use combined JS files.
    It can be done using an asset manager or using "bundles" JS files bundles.



    You need "requirement .js" dependency script for loading.
    I have not used it, but what I know, you can create dependent modules and JS functions on other modules and JS files.




Comments

Popular posts from this blog

Pass DB Connection parameters to a Kettle a.k.a PDI table Input step dynamically from Excel -

multithreading - PhantomJS-Node in a for Loop -

c++ - MATLAB .m file to .mex file using Matlab Compiler -