Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • Home
  • SEARCH
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 7577513
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 30, 20262026-05-30T17:12:25+00:00 2026-05-30T17:12:25+00:00

I am writing a user script for youtube.com, and want to insert a button

  • 0

I am writing a user script for youtube.com, and want to insert a button with the same look and feel as the other buttons on YouTube page. Things were working in the past, but have suddenly stopped working.
Have a look at the buttons in this image on top of any youtube video:

YoutubeTopButtons

So I just noticed one thing in Firebug, these buttons include text and image sub-nodes, but are not rendering the images as simple as giving a source image url to them. The ‘src’ attribute of these images (the ‘plus’ sign image, or the ‘down arrow’ image) or all other such images have exactly the same URL (of a 1 x 1 image) : //s.ytimg.com/yt/img/pixel-vfl3z5WfW.gif. But in the end they are rendered as all these different images. As a result, when I do the same in my buttons, all other CSS properties work fine, but the images are just blank.

I just want to know from html/javascript/css experts –

  1. How are they doing this?
  2. How to get these finally rendered images through CSS/javascript?

Thanks!

P.S. :
-In case a moderator wants to close this question saying it is not a programming question, it is. To know how can one achieve this kind of ‘undetectable’ html image thing, or how can a userscript still fetch that image through javascript/html/css.
– In case a moderator wants to close this question saying it is too specific (about youtube.com), it is not. It is a general question about HTML, but I have seen implemented only by YouTube so far. I am a novice.

Thanks,
Piyush

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-30T17:12:28+00:00Added an answer on May 30, 2026 at 5:12 pm

    This technique is called CSS sprites. It is used to reduce the amount of HTTP requests.

    Basically, you have only one image with all your icons (thus you only need to load one image from the server). You would use this image as a background image on your element that has a width/height defined to the size of the icon to display and play with the css properties background-position to place the background at the top/left of the icon to display in the background image.

    So the important parts are to:

    • set the image as background
    • set a size to your element. As the image is used as a background, it will not implicitly have a size from the image !
    • set the background-position rule

    YouTube is using the following image: http://s.ytimg.com/yt/imgbin/www-refresh-vflmpZ5kj.png

    enter image description here

    The image is 16px/16px sized and the top/left of the “plus” icon is at the position 97px/66px so they use the following background-position values:

    background-image: url(//s.ytimg.com/yt/imgbin/www-refresh-vflmpZ5kj.png);
    background-position-x: -97px;
    background-position-y: -66px;
    width: 16px;
    height: 16px;
    

    Further reading:

    • CSS Sprites: Image Slicing’s Kiss of Death
    • The mystery of CSS sprites

    Generators:

    • Online CSS Sprites Generator
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

hello i'm writing a GM user script and i want to change the favicon
I am writing a bash script and want to switch to another user, cd
I'm writing powershell script that simulates actions performed by user on the page. I
Writing a bash script, and I want to get user input. Awesome, read -p
I'm writing an user-driven app with several zones to it. I want to allow
I'm writing a script that will allow a user to input a string that
I'm writing a proxy script that ideally does the following things: Proxy waits for
I'm writing a script to check permissions of files in user's directories and if
I am writing a csh shell script, run where the user is expected to
I am writing a bash shell script, run where the user is expected to

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.