I have found conflicting sources on linking/referencing JavaScript to a SharePoint .HTML Masterpage in SP2013.
- Out of the box, SP2013 instructions from Design Manager interface are to
Use this drive to:
•Upload the HTML version of your Master Page •Upload CSS and js files and any other design assets
•Access design files for editing
Yea..... about storing JAVASCRIPT files inside a folder called MASTERPAGE GALLERY o.O - what were they thinking?
And this brings up the question - can I add sub-folders to Masterpage gallery at least to organize my files?
AND why is there still a folder called 'STYLE LIBRARY' located in the Site Root if the correct way to upload JS files is into the 'MASTERPAGE GALLERY' ??
Getting to the different ways of referencing JavaScript. It is very confusing on the correct way to do it. Here are the methods I have found:
- Normally the script src tag can be used to link JS files to a .html file. using something like
<script type="text/JavaScript" src="custom.js"></script> The author of Professional SharePoint Development himself suggests to do it this way and gives a great tip on wrapping a CDN in MS/ME tags to prevent SP interference
Creating a Design Manager design package
My personal opinion is that referencing through the .HTML file has been unreliable. The JavaScript stops working for no apparent reason.
I found an excellent guide comparing the Design Manager/SP2013 way vs. the Solution Package/SP2010 way.
Which method do you use and why?