Ways to display post summary without loading the entire page

I recently noticed that on my blog's home page, only the summary of posts is being displayed instead of the full posts. At first, I thought it was loading just the summary with an image and a few lines from each post. However, after running a test on a Speed-Testing website, I discovered that the entire page, including all images, was actually being loaded and then the images were being hidden. This is negatively impacting my page load speed. Is there a way to make sure that only the summary is loaded initially?

 </script>
<script type='text/javascript'>
  var thumbnail_mode = &quot;no-float&quot; ; 
  summary_noimg = 430; 
  summary_img = 500; 
  img_thumb_height = 100; 
  img_thumb_width = 120; 
</script>
<script type='text/javascript'>
  //<![CDATA[ 
  function removeHtmlTag(strx,chop){ 
    if(strx.indexOf("<")!=-1) 
    { 
      var s = strx.split("<"); 
      for(var i=0;i<s.length;i++){ 
        if(s[i].indexOf(">")!=-1){ 
          s[i] = s[i].substring(s[i].indexOf(">")+1,s[i].length); 
        } 
      } 
      strx = s.join(""); 
    } 
    chop = (chop < strx.length-1) ? chop : strx.length-2; 
    while(strx.charAt(chop-1)!=' ' && strx.indexOf(' ',chop)!=-1) chop++; 
    strx = strx.substring(0,chop-1); 
    return strx+'...'; 
  } 
  function createSummaryAndThumb(pID){ 
    var div = document.getElementById(pID); 
    var imgtag = ""; 
    var img = div.getElementsByTagName("img"); 
    var summ = summary_noimg; 
    if(img.length>=1) { 
      imgtag = '<span style="float:left; padding:0px 10px 5px 0px;"><img src="'+img[0].src+'" width="'+img_thumb_width+'px" height="'+img_thumb_height+'px"/></span>'; 
      summ = summary_img; 
    } 
    var summary = imgtag + '<div>' + removeHtmlTag(div.innerHTML,summ) + '</div>'; 
    div.innerHTML = summary; 
  } 
  //]]></script>

The above code snippet is what I've implemented in order to generate summaries.

Answer №1

Utilizing a jump-link was the perfect solution to this issue. By incorporating a jump-break, I achieved the desired outcome precisely as planned. Additionally, I enhanced the appearance of the read more button for added flair.

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

show the PHP variable in brackets

I am currently working on a project where I need to dynamically display query results in a list format. However, I am encountering issues when it comes to displaying the results between specific tags. <?php include 'dbh.php'; ...

Issue with fs.createReadStream function: it is not recognized as a valid function

I'm currently developing a project in VUE that utilizes 'fs', and I have included my code below. async Upload(file){ let fs = require('fs'); console.log(file); console.log(this.dialogImageUrl); ...

Issue encountered while transferring data using Ajax

I am a novice in the realm of ajax and currently immersed in a project that demands passing data from an ajax function to a php page for the purpose of dynamically generating and displaying modals. Although I am successful in creating the modal, I suspect ...

leveraging embedded jetty for developing a web-based interface

As a newcomer to web development and using embedded Jetty, I have created the source code below in Eclipse IDE. I need to programmatically start the Jetty server and cannot use the command line to do so. The web interface must be lightweight due to the li ...

Using Laravel to send asynchronous Ajax requests

Currently, I am trying to understand the proper way of passing a CSRF token (using Laravel) with an AJAX request. The issue I am facing is that my AJAX URL returns a 500 error because it did not receive the CSRF token. I have a few concerns regarding secu ...

Customize tax rates for WooCommerce checkout based on selection of radio buttons

Utilizing the WooCommerce plugin [WooCommerce checkout addon][1], I have incorporated an additional field on the checkout page consisting of radio buttons for multiple choice selection. My goal is to adjust the tax rate when a specific option is chosen fro ...

Difficulty in aligning elements to the edges of the screen

How can I adjust the positioning of these two arrow indicators to be aligned with the left and right edges of the screen, regardless of size? .arrow-container { position: absolute; top: 37%; width: 95%; display: grid; grid-template-columns: 10 ...

Deploying CSS/JS files in Magento 2 is a crucial

Hello, I recently set up magento2 with the sample data included. After attempting to deploy static css/JS using the command php bin/magento setup:static-content:deploy, I didn't receive any errors but the issue persists. Additionally, I am unable to l ...

Analyze XML elements and retrieve their associated content

Analyzed below are the contents extracted from the processed XML file: <dblp> <incollection> ...

Identifying the loaded CSS with jQuery

My HTML page dynamically loads specific CSS files based on screen width (for PC, tablets, and phones): <meta name="viewport" content="width=device-width, initial-scale=1"> <link rel="stylesheet" type="text/css" media="all" href="css/style.css" &g ...

Filtering Dropdown List in AngularJS with a Text Input Field and a Submit Button for Filtering Option Values

After exploring , I discovered a feature that enables users to type in a text box and filter results in a pseudo-dropdown. My goal is to enhance this functionality or come up with a better approach for users to type and filter select box options, ultimate ...

Exploring the use of functional components and iterating over objects

I am struggling with object iteration, as I am used to looping through arrays but not single objects. Within my class-based component, I have the following: this.state = { itemDetails: [] }; axios.get(`${ROOT_URL}/${itemId}?${API_KEY}`).then(res => ...

Displaying protected images in Django that cannot be downloaded

After successfully uploading and retrieving an image in a Django project form, I attempted to prevent the image from being downloadable by setting it as a background image of a div element using CSS. However, users could still access the image by viewing ...

Unexpected behavior with AJAX success function not being executed in jQuery despite console logs showing otherwise

I'm facing an issue with the following code snippet: $('a.like').on('click', function(e){ e.preventDefault(); var object_id = $(this).data('id'); var token = $(this).data('token'); ...

Change the syntax to use async-await

Is it worth converting the syntax to async-await and how can I achieve this? // ---- UserRoutes ---- router.get('/user', middlewareJwt.jwtHandler, function (req, res) { UserService.get(req.userId, (user) => successCbk(res, 200, { ...

Tips for preventing real-time changes to list items using the onchange method

I am facing an issue with a list of items that have an Edit button next to them. When I click the Edit button, a modal pops up displaying the name of the item for editing. However, before clicking the save button, the selected item in the list gets changed ...

Node.js is no longer able to fulfill promises

Imagine having an API that needs to be queried for important data. const fetchData = async () => { rootUrl = 'http://....' data = await (await fetch(rootUrl)).json() moreData = await Promise.all(data.map(async (elem) => subData = ...

Is the integer value included in the linear progression?

I have a unique setup where each time the user clicks a 'Done' button, 20 is added to a base number, x (..-40,-20,0,20,40,60..). This updated value of x is then saved in a database and displayed in real-time using Ajax. However, I am facing a ch ...

Customize the React Material UI Autocomplete with a unique dropdown menu and a convenient Add Button feature located at

Seeking assistance in creating an autocomplete feature in React using Material-ui, with a unique custom dropdown design including a button labeled Add New Element positioned at the bottom. https://i.sstatic.net/6rY99.png Various attempts have been made t ...

The live updates for user data in Firestore are not being reflected immediately when using valueChanges

Utilizing Angular and Cloud Firestore for my backend, I have a setup where users can follow or unfollow each other. The issue arises when the button text and list of followers/following do not immediately update on the front end after a successful click ev ...