Disable preload for multiple audio players

To disable preloading for an individual player I select it and enter the custom attribute: preload = “none” and it seems to work, judging by the grayed-out state of those audio players.

But is there a way to disable preloading for ALL the audio players on my site? I have hundreds of them.


You can place this jquery in your project.

$(“audio”).attr(“preload”, “none”);

This will find all instances of the audio element and add the attribute.

There are several ways to add .js to a project if you’re not sure. The easiest way is through the Code Editor.


1 Like

Thanks for your reply. I tried to do what you described, but what I tried didn’t work. I accessed a code editor using Page–> Settings and my input looked like this:

I suspect this is just for a page rather than the whole project, but I don’t see a way to bring up a code window for the whole project (I looked under File–>Project Settings…, did a search for “Code Editor” in the documentation and in this forum and came up with nothing in each case)

Also, I’m confused: will this change my Blocs project the way I requested? Or is this a “fix” that will only apply at the time pages are viewed in a browser? While programming tricks are very cool, I’m interested in simplicity. I’m just asking how to make mass changes in my Blocs project.


This does exactly what you want. A mass change across and entire project provided you add the code in the right place.

I can tell from screenshot that you’re using a version before me. I’m using Beta and I’ve lost track of which version has what at this point… but no worries.

  1. For your version place code in a .js file.


jQuery(document).ready(function($) {
$(“audio”).attr(“preload”, “none”);

  1. Upload that file via Project Settings --> Project Attachments (this is in docs)

Note: It’s similar to using the page settings except it’s for the entire project.

This is exactly what you are doing when you add these attributes in blocs. Javascript is used to apply that attribute to the element, no different. Everything happens in the browser, that’s the nature of Javascript… it needs the browser to run. This is how everything you’re doing in blocs is achieved. Javascript is used to place the classes, attributes, HTML. You preview or export and the browser either standalone or inside of Blocs app does it’s thing.

Hope that helps.

I made an addition above in case you aren’t familiar with making .js files. You’ll want to wrap your code in a doc ready for best results.

1 Like

@Whittfield I appreciate the efforts you’ve made to help. Thank you. However, I have to report that nothing I’ve tried based on your suggestions has helped. I thought for the sake of others I’d complete this thread with my results.

First, I decided to download the latest beta (build 5) and enter the code you provided using Window–>Code Editor:

Second, I tested and found that it did not work; judging by my observation (in different browsers) that all audio players were still pre-loading (except the ones I manually changed attributes for).

Third, I checked to see if your approach makes changes to my Blocs project. It doesn’t (just as you said), confirming my notion that your approach is a “programming trick” which (while perhaps very cool) does not address my simpler question “how can I make this mass change in my Blocs project”

Therefore, I conclude that there is no way to change the attributes of multiple blocs (e.g., audio players) in a Blocs Project.

I’m not sure how posts get marked “SOLVED” but someone marked this that way despite my clear statement otherwise. Although I appreciate Whittfield’s help very much and have learned from him, his posts do not address whether one can make mass changes in a bloc project. The blocs project is unchanged by his approach, as clever as it may be.

@Tony There is no trick. Attributes are added to elements using javascript. I have already found your problem.

  1. I notice that you didn’t add the code I amended with the jQuery(document).ready
  2. There are “curly quotes” in my original post. I’ve re-posted the code so the curly quotes are no longer an issue.

Copy it from here… (but looks like you may have figured that part out form the screenshot)

jQuery(document).ready(function($) {
$("audio").attr("preload", "none");

Here’s a screenshot of the script doing it’s thing. I’m inspecting the page with multiple audio players and they all have preload attribute added to them. Any audio player on any page get’s the same attribute added.


1 Like

@Tony , I was thinking, the presence of the autoplay actually overrides the preload in the audio spec. That means you also need to turn off the autoplay for the preload attribute to work at all.

If you’re interested in doing that in bulk as well. The code below shows how.

But don’t forget that you’ve set the attribute for these elements in the Blocs UI, however you can simply remove this code and all of your original autoplay settings will still be there.

jQuery(document).ready(function($) {
$("audio").attr("preload", "none").removeAttr("autoplay");