Following the examples I found, here is how I add jQuery to a page:
- Add the jQuery source files to Site Assets.
- Create a .js file in Site Assets with my script, including references to source files.
- Create a new page.
- Add a Content Editor Web Part (CEWP) to the page.
- Set the Content Link of the CEWP to my .js file.
- Save and Publish.
Now, the script works perfectly fine, if I am logged in as an Administrator. But, if I visit my site as an Anonymous user, the script works, but the theme is not loaded. I get a plain white background. I get the same results whether in Chrome or IE 11.
To eliminate variables, I created a new page and added code to the .js file one line at a time. Here is the smallest script that breaks the theme:
I am not seeing any typical error messages. So, my question is two-fold: How can I display error messages that tell me why the theme is failing to load, and does anyone have a solution to this problem?
Robert Lindgren suggests using a Script Editor Web Part instead. Fair enough, but it doesn't allow referencing a file (Content Link) like a CEWP does. So, I put just this code into a Script Editor Web Part (I remove the jQuery references) and I get the same behavior:
Screenshots as requested. At this point, I have cleared out Edit Source and have JUST the label on the page:
<label id="lblSomething">Here is something!</label>
and a Script Editor Web Part with just the JavasScript. No jQuery, no referenced files, to help eliminate variables:
Full disclousure, I am editing in Chrome and testing against IE, but that's just so I don't have to log out and in again. I have tested against both browsers, also cleared caches, it doesn't change the behavior.
When I am logged in as Site Administrator (Chrome).
UPDATE 3: I also have an Office 365 site that I host. I recreated the same situation there, and I do NOT have the same problem. So this is something particular to my hosting company, or Microsoft does something different with Office 365 sites.