Enhance the speed of my Tumblr page by using JavaScript for personalized styling tweaks

-- Hey there!

Dear Reader, if navigating Tumblr isn't your cup of tea, let me know and I'll provide more detailed instructions!

I recently ran into some glitches on my Tumblr page while using the default theme 'Optica'. Whenever I tried posting an embed SoundCloud track, this is what showed up:

see image below

NOTE: Switching themes didn't solve the issue entirely. Some themes worked fine, while others still had the same bug.

In an attempt to fix it, I pinpointed the root cause in the main.css stylesheet under the following code snippet:

.video .video-wrapper {
background: #111;
position: relative;
padding-bottom: 56%;
height: 0;
}

To embed a code, Tumblr requires the use of the "Video post" tool on your dashboard, allowing you to style the embed with the .video-wrapper class.

The challenge I faced was reducing bottom padding without affecting all Video posts. To get around this, I utilized the existing class .soundcloud_audio_player within the iframe to distinguish these specific Video posts for styling purposes.

Simplifying things, here's how it finally appeared in the browser:

<article class="audio not-page post-70801339374 " data-post-id="post_70801339374">
<div class="post-wrapper clearfix">
    <section class="post">
        <figure>
            <div class="video-wrapper">
                <iframe class="soundcloud_audio_player" />
            </div>
        </figure>
        <section class="attribution-tags clearfix">
            <ul>
                <li>
                    <a href="http://hymced.tumblr.com/tagged/SoundCloud" class="tag">SoundCloud</a>
                </li>
                <li>
                    <a href="http://hymced.tumblr.com/tagged/Blutch" class="tag">Blutch</a>
                </li>
            </ul>
        </section>
    </section>
    <section class="panel" />
</div>
<article>

This is what I included between the tags in my custom Tumblr HTML:

<script type="text/javascript" src="http://www.google.com/jsapi"></script>
<script type="text/javascript">
google.load("jquery", "1.3");
google.setOnLoadCallback(function() {
    jQuery(function($) {
        $("iframe.soundcloud_audio_player").parents('div.video-wrapper').css("padding-bottom", "17%");
    });
});
</script>

Judging by my lack of JavaScript and jQuery knowledge until today, I opted for jQuery assuming it was simpler. Problem #1 resolved! But now... PROBLEM #2

While the page loads, the initial styling (before JS kicks in) briefly displays for a second or two (depending on my bandwidth), making it look rather unsightly:

refer to image below

I scouted around here and here but couldn't find a solution to enhance loading speed. I'm counting on you folks to lend a hand :)

PageSpeed test results down below

Answer №1

It seems like you want to conceal the fact that styles are changing once the page has finished loading - To achieve this effect in a simple manner, follow these steps:

Include this code snippet in your HTML:

<div id="cover"></div>

Next, add this CSS styling:

div#cover {
     position:fixed;
     height:100%; width:100%; 
     background:white;
     z-index:999;
 } 

The z-index may not be necessary depending on your setup. Check out various preloaders as alternatives to this method.

Lastly, in JQuery:

$(document).ready(function(){ 
    // Insert the code to adjust the padding of your iframe and any other necessary setup tasks here... 
    $("#cover").hide();   // This will reveal your page! 
});

Similar questions

If you have not found the answer to your question or you are interested in this topic, then look at other similar questions below or use the search

Looking for a way to focus on an element similar to `event.target.focus()`

I am in the process of developing a dynamic list component that generates an empty text field every time an item is added to the list. The structure of the component is shown below: const DynamicInputList = ({ inputs, onChangeArray, label, name, errors }) ...

Is there a way for me to retrieve the UrlMatcher from ui-router?

While exploring the ui-router documentation, I came across an object called UrlMatcher. This object contains useful methods like exec, but I am struggling to find clear instructions on how to access it. Nevertheless, the documentation page provides a detai ...

Styling may vary between the CSS used in the development environment and the one

After launching my web page on a server yesterday, I noticed some differences compared to the development environment. There are a few elements with altered colors, but my main concern is the appearance of the jQuery autocomplete search widget. Instead o ...

Using jQuery to properly align two tables

My challenge involves managing a large gridview within a scrolling container that has a fixed height. To prevent the header from scrolling along with the content, I placed the header in a separate section. This setup results in two tables - one inside the ...

The appended element continues to add infinitely as you scroll, when it should only be appended once

I have successfully added a div to a form after scrolling, but now I am facing an issue where this div keeps appearing indefinitely as the user scrolls. You can view this troublesome div on the following website: . It is the close button that appears at t ...

Error in TypeScript detected for an undefined value that was previously verified

I have developed a function that can add an item to an array or update an item at a specific index if provided. Utilizing TypeScript, I have encountered a peculiar behavior that is puzzling me. Here is the Playground Link. This simple TypeScript functio ...

Is it possible to adjust the position of a h2 heading on a particular webpage using CSS?

There is a situation where multiple pages contain h elements nested inside a standard container div class. When trying to edit a specific h2 element in a specific page using CSS, simply editing the h2 or the container does not work. Other methods attempte ...

Tips for organizing nested form rows with Bootstrap 4

I am currently working on a nested form row and I am looking to align the form fields vertically. The current output I am getting is shown below: https://i.sstatic.net/NEWGY.png Here is the code snippet: <link rel="stylesheet" href="https://maxcdn ...

Transform basic list into a two-dimensional array (grid)

Picture a scenario where we have an array: A = Array(1, 2, 3, 4, 5, 6, 7, 8, 9); We aim to transform it into a 2-dimensional array (a matrix of N x M), similar to this representation: A = Array(Array(1, 2, 3), Array(4, 5, 6), Array(7, 8, 9)); It's ...

Encountering a CORS header issue while working with the Authorization header

Here is the code snippet I am currently working with: https://i.stack.imgur.com/DYnny.png Removing the Authorization header from the headers results in a successful request and response. However, including the Authorization header leads to an error. http ...

Retrieving selected values from an ngx dropdown list

I am having trouble implementing ngx dropdown list in this way: <ngx-dropdown-list [items]="categoryItems" id="categoriesofdata" [multiSelection]="true" [placeHolder]="'Select categories'"></ngx-dropdown-list> ...

The art of breathing life into UpdatePanels

Although I have experimented with the UpdatePanelAnimationExtender from the Ajax Control Toolkit, my main issue with it is that it does not wait for the animation to finish before loading new content. What I aspire to achieve is: Commence asynchronous r ...

Arrange a set of items using AngularJS according to specific criteria

Hello, I'm new to Angular I've created an angular app and you can view it in this plunkr. Can someone guide me on how to sort the list displayed here using angular? I want the course with the flag to always stay on top, while sorting the rest o ...

Retrieve the data in the format of [1,2,3] from a MySQL database by employing PHP and jQuery

I'm currently working on a jQuery code that connects to getdata.php. The val in this code is a dynamic value and the function gets called every time an option is selected from a dropdown. function getMoleculeData(val){ var molval=val; ...

Performing a single AJAX call from a JavaScript loop is more efficient than iterating through multiple AJAX calls

I am working with a 2D array in JavaScript. Currently, I have a for loop where I make an AJAX call to update the database. I understand that this approach is not efficient, and I am seeking a way to update the database with just one AJAX call within the ...

Is there a method to obtain the compiled CSS for an Angular 2+ component?

Is it possible to retrieve compiled CSS (as a string) from an Angular2+ component? @Component({ selector: 'test-graph', templateUrl: './test-graph.component.html', styleUrls: ['./test-graph.component.scss'] }) export cla ...

HTML5 Boilerplate and optimizing the critical rendering path by deferring scripts and styles

Previously, I constructed my website layouts using the HTML5 Boilerplate method: incorporating styles and Modernizr in the head section, jQuery (either from Google CDN or as a hosted file) along with scripts just before the closing body tag. This is an exa ...

Pressing a button meant to transfer text from a textarea results in the typed content failing to show up

Having trouble with a custom text area called a math field. I'm currently interning on a project to build a math search engine, where users can input plain text and LaTeX equations into a query bar. The issue I'm facing is that sometimes when th ...

Is there a way to incorporate a base64 encoded image from a text file into an HTML image?

I have several images stored as base64 blobs in a remote location. Let's focus on one specific image: llorkcir.txt data:image/jpeg;base64,/9j/4AAQSkZJRgABAQAAAQABAAD/2wCEAAkGBxISEhASEBAQDxAQDw8QEA8PEA8PDw0PFRIWFhURFRUYHSggGBolGxUVITEhJSkrLi4uFx8zODMt ...

Sliding out list elements with jQuery ladder effect

I'm stuck on a seemingly simple task and need some guidance. facepalm. Currently, my site at this link has a menu list item issue where they all come out from the left side after the picture loads. I want them to slide out one by one, starting from t ...