Streaming live at 10am (PST)

HTML Embed - SVG Code Too Long


#1

Hi Everyone,

I'm trying to create an interactive map using this resource: http://www.html5interactivemaps.com/us-state-maps/interactive-map-of-north-carolina.html

The HTML code is around 70,000 characters because the map is SVG—it's way too much for the HTML embed character limit. Any suggestions for how to do this?


Embed HTML 10,000 characters
#2

hey @fmcausby

you might want to host the script externally and then just reference it where you need it to appear.

Similar issue here;


#3

Thanks @AlexManyeki! So I'm able to host the scripts and CSS in my dropbox and call them. This may be a silly questions, but how would I call HTML that's hosted externally on my dropbox in Webflow?


#4

I would not suggest hosting on dropbox and such. Seriously impacts load times.

Try to host on cdnjs.com or jsdelivr. (google and see how to)

to use that script in your webflow project. You would just need to drop a html embed where you need it to appear and reference the script like this;

<script src="//cdnjs.com/path-to-your-script.js" type="text/javascript"></script>

Thats all.


#5

Awesome, thanks for the tip. So my only remaining problem is that for these maps, I have to paste HTML into the page. The problem is the HTML includes some SVG code that's super long (70,000 characters) so I'm not able to just paste it into a HTML embed in Webflow.

Is there a way to link to this HTML similar to the way I'm linking to JS and CSS? Looking at this W3 method for including HTML: https://www.w3schools.com/howto/howto_html_include.asp Am I on the right track?


#6

Sure. For html, this will work. Let me know how it goes.


#7

Hm. Still struggling. Here is my public site: https://preview.webflow.com/preview/forrests-sandbox?preview=f381ab4d3e21cbf4c8b8be67c8f2de07

I've put all the JS and CSS and one html file into dropbox for now (I'll look at a better alternative for hosting/calling next).

I've called the JS and CSS in the head of the page.

I've used the W3 method to try and call the HTML snippet from dropbox.

And I'm not seeing anything. Probably an amateur mistake here...any ideas?


#8

Yeah,

Its in the way you are calling your dropbox links;

replace all www.dropbox.com references with dl.dropboxusercontent.com. The former is a sharing link to the download page and not to the raw file itself;

For instance;

https://dl.dropboxusercontent.com/s/dri77wfcftmkyu4/map-interact.js is the correct reference to map interact.js

See more info here;


#9

It works! Can't thank you enough @AlexManyeki, much appreciated!


#10

Great to know. Enjoy.


#11

@AlexManyeki, you mentioned above to host the scripts on CDNJS or jsdelivr instead of dropbox. I have these scripts, as well as the HTML file and some video. Could I host these on my own website and call it from there? Any issues you see with that?


#12

None at all. Do you plan to export the site or host with webflow?


#13

I'm hosting this site with Webflow. The other website is hosted elsewhere and I have FTP access. I noticed Webflow just added hosting for documents which I've been hoping for. Maybe one day they'll have a way to do this sort of thing without going outside Webflow.

Thanks again for all the help @AlexManyeki!


#14

Very Welcome @fmcausby


#15

@AlexManyeki, sorry to both you again with this. I'm trying to get this to work.

First of all, I'm trying to use a link from my own website for the HTML snippet (as mentioned above). For some reason I can get the map to show up on the published site when I pull the snippet from Dropbox, but not from my own site. The link to my own site works (if you open it in another window, you can see the map) and nothing else about the code has changed.

Secondly, the javascript and CSS aren't working. The map should have dots and county rollovers but it's not showing up. What is really strange is that occasionally it WILL work. I won't change a thing and come to the page and it works. It's just very unpredictable.

My public site is here, the HTML embed pulling the map is on the page called "Chapter 2" about halfway down. I currently have one embed pulling the snippet from dropbox, another one trying to pull it from my website.

Any ideas?


#16

So strange, not the map isn't loading at all, either from dropbox or my own site. I'm worried about how finicky this is, I want to make sure it's more reliable on the final site. I'm wondering now if it's just a speed thing. Perhaps it's just loading really slowly.


#17

Hey @fmcausby

the w3.includeHTML(); tag should be called in the footer and not within the script itself;

the embed code should only have;

<div w3-include-html="http://www.mcreative.net/client/zsr/code/map.html"></div>

The script that calls this html;

<script>
w3.includeHTML();
</script>

should be included only once in the footer section of custom code (before </body>). This should work but let me know of the outcome.


#18

Thanks Alex, I did that and the Dropbox version still works but the one to my website still isn't working.

Right now I can pull the HTML snippet from Dropbox, but not from my site.

And I can't pull the javascript from either. (Or maybe it's just so slow it takes forever to show up? I am calling a lot of JS.)


#19

Huh. I ran a speed test at Pingdom. (You're right the dropbox content loaded very slowly.)

I noticed that the map.html I'm pulling from my site had an error.

From what I could see the JS from my site is loading with no trouble, I think?

It's also strange that in the source for the published site the dropbox include shows up as all the code from the HTML file I'm pulling. The include from my site simply has the HTML embed code from dropbox. For some reason it's not firing. I wonder if it has something to do with my link or with where my site other site is hosted.

Wondering if the following errors make sense to anyone out there?


#20

I think this has to do with cross domain requests... I dont know much about this but the issue is easily resolved by using a secure CDN.

The hosted html will not load from some domains until those permissions are explicitly declared.

See here for some reading material;