Setup question

15 replies · opened Mar 16, 2023

CcadilhacMar 16, 2023

Hi,

I'm using Canvas in an asp.net core project.
functions.js is loaded with:

``

My homepage is www.mysite.com/en

Your scripts and all subscripts are loading fine.
However, when I navigate to another page like www.mysite.com/en/projects I see that functions.js try to load subscripts incorrectly. When checking in console, I see for instance that it tries to load /en/js/fn.logo.js instead of /js/fn.logo.js. This is quite surprising since I explicitely requested functions.js to be loaded from the root.

How do I solve this?
Thanks

Nicolas

CcadilhacMar 16, 2023

After checking the functions.js file, I am wondering why you load plugins relative to the url path...
To my mind, it would be better to either load them from a base path like /js or by smartly loading them from the same path than functions.js was loaded.

As a workaround, while waiting for your solution, I modified functions.js loadJS function to prepend '/' before the path.

Also, why is there no unminified functions.js. This would allow for better investigation and your customers could help you find bugs or debug the code easily.

Thanks

Nicolas

SSemicolon WebSTAFFMar 16, 2023

Hello,

The Latest js/functions.js File fixes this issue, however, with the Plugin Loading there is still a small bug. Allow us some time and we will provide you with the Files along with updating the Package shortly. Apologies for the Inconveniences on this, we are still fine-tuning this based on exact user requirements. Thanks for your Kind Patience.

Meanwhile, do let us know if we can help you with anything else or if you find any further issues with Canvas.

CcadilhacMar 17, 2023

Thank you.
Indeed, some files can now load correctly but not all of them. For instance, on my page, jquery.js and the parallax module are not loaded correctly. Eager to download your fixes on this. Thanks for the fast reactivity.

Nicolas

SSemicolon WebSTAFFMar 17, 2023

Hello,

Very Happy to Help! :)

We have already fixed this and an update will be released shortly. Thanks for your Patience.

Meanwhile, do let us know if we can help you with anything else or if you find any further issues with Canvas.

CcadilhacMar 20, 2023

Unfortunately, with the latest version of this WE, jquery and other plugins.* files are not loaded correctly with an absolute path. modules.* files are loaded correctly.

SSemicolon WebSTAFFMar 20, 2023

Hello,

We have just checked this and we can confirm that this works fine for us. Other Users have also confirmed that this issue was resolved. Please provide us with a Live URL so that we can check out the exact issue and provide you with more accurate assistance on this. Thanks for your Patience.

Meanwhile, do let us know if we can help you with anything else or if you find any further issues with Canvas.

CcadilhacMar 20, 2023

I have no live web site yet.
So here is what I did: I unminified functions.js and put a breakpoint in LoadJs.
As you can see on the screenshot, the function tries to load "js/jquery.js". Note the absence of leading slash. So it still tried to load the script relatively to the current url.

In short, after seeing your code, it can't work for you, me and other users if the url has multiple segments.

CcadilhacMar 20, 2023

Note also that if I set jsFolder in functions.js equal to '/js/' instead of 'js/' it fixes my issue.

On a side note, I wonder how js loading could work before I reported this bug. if I load a page with url /user/details/123, it does not make sense to request /user/details/js/xxxxxxxx.js. Javascript files always have to be loaded from the root, not relatively to the current url path. I am puzzled with that.

SSemicolon WebSTAFFMar 21, 2023

Hello,

Apologies for the Inconveniences caused!

We did run many tests on this, even on the Servers and it did work fine for us. We will look into this again and it would be amazing if you can please provide us with Live URL whenever you are ready so that we can understand your use-case in a better way and fix this for you promptly. Thanks for your Patience.

Meanwhile, do let us know if we can help you with anything else or if you find any further issues with Canvas.

CcadilhacMar 21, 2023

Hi,

You don't need a live server from me because you can replicate it locally on your dev machine.
In your template distribution, here is what I did this morning to reproduce the issue:

Alongside all the html files, js and css folders, create a new "test" folder. Copy index-classic.html in the test folder.
Modify the html file so that it links to the needed files as absolute paths instead of relative paths (especially replace js/functions.js by /js/functions.js - css and images paths are not necessary to replicate the issue).
Using Visual Studio code and your live server extension of your choice (I'm using ritwickdey.LiveServer), or your own local server, start the server (from the "Canvas7 Files" folder) and navigate to https://localhost:port/test/index-classic.html.
In the Network tab of the browser debug panel, check that jquery and other plugins are not loaded correctly since it tries to load them from the test folder instead of the root.

Note that if there is an issue with js files, there may be an issue with css files when referenced as absolute paths too... But I don't know in which circumstances it could happen. I understand that your code loads plugins when needed. Do you also load CSS dynamically sometimes?

SSemicolon WebSTAFFMar 22, 2023

Hello,

Thanks so much for the detailed feedback. We will look into this and run more tests to thread out the issues. Thanks for your Patience.

No, CSS is loaded dynamically only for this Shortcode: https://canvastemplate.com/code-highlighter.html .

Meanwhile, do let us know if we can help you with anything else or if you find any further issues with Canvas.

CcadilhacMar 29, 2023

Hi,

Some news about this please?
I saw a new update mentioning loading JS in different manners, but there is nothing in the doc about it.
Thanks

Nicolas

SSemicolon WebSTAFFMar 30, 2023

Hello,

We have already updated the Documentations here: https://docs.semicolonweb.com/docs/getting-started/javascript/ . We have already included a Combined File in the Latest Update named: js/plugins.js File. Now you can simply use this file to directly without the need to define any JS path manually. Simply use the following code replacing the existing js/functions.js JS File Linking:
[ch_pre]
[/ch_pre]

You can point these files directly to your absolute folders:
[ch_pre]
[/ch_pre]

Hope this Helps!

Let us know if we can help you with anything else or if you find any further issues.

CcadilhacMar 30, 2023

Thank you. It seems to work, but:

  1. It's a pity you could not make it as a simple /js/functions.js instead of explicitely loading jquery and then scripts instead.

  2. It's a pity that your doc does not even mention this notion of absolute path. People with the same issue, and I guess they are numerous since this is not everybody that simply loads all web pages with a single level from the root, won't know that they have to replace functions by jquery+scripts.

SSemicolon WebSTAFFApr 1, 2023

Hello,

  1. There are too many parameters involved and everyone's use case is not the same, so we have to tread carefully before making any major changes to the core files to prevent it from breaking websites. This is a safer way to load the files without causing any issues.

  2. Thanks for pointing this to us. We are working on that as we are changing the structure of our Documentations. As of now, Canvas 7 has been download 12000+ times and only 14 users have asked for Absolute JS Folder use-case, so we are still trying to make this work in a better way.

Thanks for your concerns.

Meanwhile, do let us know if we can help you with anything else or if you find any further issues with Canvas.

Have the same question, or something new?

Sign in to the Canvas dashboard to reply or open your own topic. Canvas owners get direct help from the SemiColonWeb team.

Reply on the dashboard