Business
Jobs
  • About Us
  • Solutions
    • Job Postings
      Post your job and receive qualified candidates in 48h.
    • Candidate Assessments
      500+ technical and psychological tests, plus anti-fraud.
    • Headhunting
      Tailor-made executive search from start to finish.
    • Payroll + EOR
      Payroll dispersal and EOR across 15+ LATAM countries.
  • Pricing
  • Jobs

0

79
Views
Apply style to images before they are loaded

Particularly I am interested in applying style for images and background images. The style is injected with a CSS class into the page from a chrome extension. I have no direct control over elements on the page but only through my js script which is injected into webpage when it is open. The class that is applied to every element before the page is loaded with DOMContentLoaded event listener is smth like that:

function insertClass(){
 //find all elements with img tag or background style
 //add style to those elements
}
document.addEventListener('DOMContentLoaded', insertClass})

Eventhough, according to the description of DOMContentLoaded the function should run before the element is loaded, I still have a visual of images without the style applied for a split second, meaning that style is applied after the image is rendered. Is there a way to apply style before the image is rendered?

about 4 years ago · Juan Pablo Isaza
1 answers
Answer question

0

maybe it is just a typo, but there is an extra } in document.addEventListener('DOMContentLoaded', insertClass}), after insertClass

about 4 years ago · Juan Pablo Isaza Report
Answer question
Find remote jobs

Discover the new way to find a job!

Top jobs
Top job categories
Business
Post vacancy Pricing Sales
Legal
Terms and conditions Privacy policy
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Show me some job opportunities
There's an error!