Skip to main content
Inspiring
February 11, 2018
Answered

javascript loading order in panels

  • February 11, 2018
  • 1 reply
  • 1368 views

I am totally confused.

When I open my panel, jquery doesn't want to load. If I then open debug and refresh debug window – jquery loads correctly.

I tried putting my <script> tags:

- in the <head>

- at the end of <body>

- with defer set

- with async set

Also tried different jquery versions

Nothing helps.

If I close and re-open my panel tab – jquery isn't there. If I refresh in debug – it's there.

Any ideas?

This topic has been closed for replies.
Correct answer Trevor:

In manifest.xml

<CEFCommandLine>

    <Parameter>--mixed-context</Parameter>

</CEFCommandLine>

In index.html

<script>

if (typeof module === 'object') {

    window.module = module;

    module = undefined;

}

if (typeof exports === 'object') {

    window.exports = exports;

    exports = undefined;

}

if (typeof require === 'object') {

    window.require = require;

    require = undefined;

}

</script>

<script src="../js/libs/jquery-3.1.1.min.js"></script>

<script>

if (window.module) module = window.module;

if (window.exports) exports = window.exports;

if (window.require) require = window.require;

</script>

I put mine in header but it's not crucial.

HTH

Trevor

1 reply

Trevor:
Trevor:Correct answer
Legend
February 12, 2018

In manifest.xml

<CEFCommandLine>

    <Parameter>--mixed-context</Parameter>

</CEFCommandLine>

In index.html

<script>

if (typeof module === 'object') {

    window.module = module;

    module = undefined;

}

if (typeof exports === 'object') {

    window.exports = exports;

    exports = undefined;

}

if (typeof require === 'object') {

    window.require = require;

    require = undefined;

}

</script>

<script src="../js/libs/jquery-3.1.1.min.js"></script>

<script>

if (window.module) module = window.module;

if (window.exports) exports = window.exports;

if (window.require) require = window.require;

</script>

I put mine in header but it's not crucial.

HTH

Trevor

AverinAAAAuthor
Inspiring
February 12, 2018

That is some dark voodoo magic

Davide_Barranca12040269
Legend
February 23, 2018

You may want to look here, for the reason why dark voodoo magic works :-)

Davide

Davide Barranca - PS developer and authorwww.ps-scripting.com