0

Im working with Sharepoint Online (0365), that is setup in classic mode, we just migrated over and attempting to set a few sites up, but have a challenge around the Minimal Download Strategy.

The reason: I have have some custom HTML, Java, and CSS that im importing into pages using Content Editor, and using div blocks for parts of the output from the java (for example i have a HTML page that is setup for a Side menu that is in the top right, while i have a main menu on the left - some of these parts i want to cascade to multiple sub-sites).Im uploading the code into the Site Assets folder, and calling the CSS and JAVA via Style and Script source tags.

The code its self works, however as i make changes to the code, it doesnt update the code called. If i clear the cache, it updates fine.

In the past using 2013 disabling the minimal download strategy worked as expected but on Sharepoint Online - it doesnt seem to?

6
  • Please add your code in the question. The html/css selectors in SPO are not the same as SP13. Please check them and adjust your code accordingly. Commented Sep 27, 2019 at 15:58
  • I could be wrong but I don't belive the issue is related to the code, as it's firing as expected and works in 2013. The issue I think I'm having is related to the files not pulling in the browser after I refresh (after I have modified the code). - for example I'm using a list for links, I accidently added an extra > and when I corrected it, uploaded the code, and refreshed the extra > was still there until I cleared the cache.
    – K Henson
    Commented Sep 29, 2019 at 3:38
  • I did have the same challenge in 2013, but after disabling MDS the issue was resolved but in SPO this appears not to be the case.
    – K Henson
    Commented Sep 29, 2019 at 3:42
  • Test it for other users or on other machine as well. Commented Sep 29, 2019 at 3:42
  • That was actually how I found out about the issue, another user was checking progress called out the typo, after I fixed the issue, they Checked again the issue was still present I enabled and disabled MDS then refreshed and it didn't pull the updated file in (looking through the developer tab in Chrome I confirmed it was still the old code).
    – K Henson
    Commented Sep 29, 2019 at 3:57

1 Answer 1

0

Try to append a version wherever you are referring the JavaScript as example below. it will solve your issue.

<html xmlns="http://www.w3.org/1999/xhtml">
<head>
    <meta http-equiv="X-UA-Compatible" content="IE=Edge">
    <script type="text/javascript" src="/_layouts/15/sp.runtime.js"></script>  
    <script type="text/javascript" src="/_layouts/15/sp.js"></script>  
<script type="text/javascript" src="/sites/abc/SiteAssets/Task%20Form/JS/jquery-3.3.1.min.js"></script>
<script type="text/javascript" src="/sites/abc/SiteAssets/Task%20Form/JS/jquery-ui.js"></script>
<script type="text/javascript" src="/sites/abc/SiteAssets/Task%20Form/JS/BHQNewEditScript.js?v15"></script>
<link rel="stylesheet" href="/sites/abc/SiteAssets/Task%20Form/JS/jquery-ui.css">
<link rel="stylesheet" href="/sites/abc/SiteAssets/Task%20Form/BusinessQueryHandlingForm.css?v15">
</head>
<div class='divMain'>
</div>

in above example you can see i have appended v15 in our custom Javascript and CSS files. This method need to used even we you are pushing code changes after post production issue.

7
  • It is not a good practice to add html tag in CEWP or Script Editors. Commented Sep 27, 2019 at 16:00
  • @harshal i have not asked to add in CEWP, but wherever he is referring might be he is using some.html file in Content Editor. there he can do the change. Commented Sep 27, 2019 at 16:07
  • I am using a html file, but html and body tags are omitted. I'm also using just CEWP to add my code in (the company I work for doesn't want us editing the actual pages or creating master pages - basically they don't want to support it if we break it). I do understand what your suggesting though, is there any documentation that I can read for it? (the ?v15 is not something I have seen before, is it a sharepoint thing? ) - also thank you for the suggestion!
    – K Henson
    Commented Sep 29, 2019 at 3:50
  • Doing some quick reading on this, if I understand correctly the ?v15 isn't an attribute in the file or a query, it just forces the browser to pull a fresh copy as it thinks is a different file than what's already in the cache. - when I get to the office on Monday I will try this out!
    – K Henson
    Commented Sep 29, 2019 at 4:09
  • Yes, You read it right. you can append anything after the "?" either a date or version which browser will treat a new version of your JS or css file. same thing you can observe when you do F12 and try to see any Microsoft JS files they will have some token appended. its tested and implemented in large Office 365 customisation project and in PROD environment you no need to ask every user to clear the cache Commented Sep 30, 2019 at 8:32

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.