Streaming live at 10am (PST)

How can I change type attribute from text/javascript to text/plain?


#1

Hello,

I’ve implemented ‘Cookie- Script’ which was pretty easy. But now I’ve to change ‘type attribute from text/javascript to text/plain’ to block third party cookies (as described here https://cookie-script.com/how-to-block-third-party-cookies.html)

How/where can I do this in Webflow? I asked Cookie Script and they answered:
'you have to change HTML code of your website, not JS, in order to block third-party cookies. Ask Webflow if there’s such possibility.

Also if there’s no, maybe they let you to change and add “attributes” of inserted elements (html tags) from their web (admin panel) interface. Please ask them as well and if so, probably you could achieve what you want.’

I hope someone can help me so I can finish this project.

Read only link is: https://preview.webflow.com/preview/ncp?utm_source=ncp&preview=487259e0e9fe11a7d10547ce206a826e

The Published link is: http://ncp.webflow.io/

Kind regards,

Bastiaan


#2

Webflow itself should not place any cookies on your website. At least it doesn’t for us. All cookies set will be from scripts that you put in the custom code section yourself. Apparently you have to change the following:

<script type="text/javascript" src="myscript.js"></script>
to
<script type="text/plain" src="myscript.js"></script>

If you use webflow for tracking with Google Analytics however, you won’t be able to do this. Just deactivate it in webflow and place the script yourself.


#3

Thanks Andre, I use embedded Youtube and Vimeo video’s in the site which place cookies. Where can I change the type attributes for these scripts / code?


#4

Funny, I wondered the same a while ago. Turns out you can’t, as long as you are using webflow’s video element. Have a look at my question:

To be 100% GDPR compliant, you have 2 choices:

So for now, we can only use video’s with custom iframes, if we don’t want YT to set cookies (by default).

or not using videos at all.


#5

also it would not work anyway with cookie monster, since you can’t alter the iframe code that webflow’s video element comes with. maybe something like this would work in theory:

  1. use youtube’s privacy url (cookie will only bet set once the video is being played) --> not possible bcs the privacy url is not supported by webflow
  2. run custom code to alter the iframe code as required by cookiemonster
  3. AFTER this, run cookie monster code

but as i mentioned, this is currently not possible with webflow. also it’s pretty dirty, bcs there is a time frame between the video being loaded and the code adjusting the iframe + cookie monster running, where a user might already click the video and the cookie is getting placed.


#6

Hmmm… How did you solve this? With custom iframes? Visitors must have the possibility to decline those cookies. Otherwise it is not GDPR compliant


#7

we didnt… i texted webflow a few months back and they said they will have a look into allowing privacy urls for youtube. But they never got back afterwards. i’ll email them again.

for now the best solution would probably be to build a custom youtube container with the embed element. but then you can not use videos in rich texts anymore.


#8

Building a custom youtube container isn’t possible because my client has also Vimeo video’s which he can add within a CMS collection.
Hope Webflow will make a custom Webflow cookie consent banner / solution which is GDPR compliant.

Thanks Andre!


#9

So webflow’s answer was that they are still working on allowing youtube’s privacy urls. For now the recommended workaround is to use a custom embed element for showing videos.

does your client want to add the video in a rich text (like in the body of a blog post), or is it a seperate field for the video only? If if is a seperate field, you could write a custom coded solution that loads the video only if cookies are accepted.


#10

Hi Andre, it is a seperate field for the video only (youtube or vimeo). I think I’ll wait for Webflow’s solution because I can’t write a custom embed element.


#11

you could try an embed element with this code (should work with cookiemonster):

<!-- video will be inserted here -->
<div id="cms-video-container"></div>

<!-- script gets called by cookie monster if cookies were accepted -->
<script  type="text/plain" data-cookiescript="accepted">
/* Instead of VIDEOURLFROMCOLLECTION, you should pull the field from the collection. 
Webflow's embed element let's you do that. */
var video = $('<iframe width="560" height="315" src="VIDEOURLFROMCOLLECTION" frameborder="0" allow="autoplay; encrypted-media" allowfullscreen></iframe>');

$('#cms-video-container').append(video);
</script>

In the collection there would then just be a text/url field where you put the video url. If cookies are accepted, cookie monster will run that script, and an iframe with the video will be inserted. If cookies were declined, nothing will happen.

Note that I didn’t test this.


#12

Thx! I’ll give it a try soon.


#13

Hey guys, I created a wishlist item for dealing with the video issue:
https://wishlist.webflow.com/ideas/WEBFLOW-I-1540


#14

Great, you have my vote :smile: