search

Home  >  Q&A  >  body text

javascript - The front-end of many web pages is a whole picture cut out with many small materials such as button icons, etc. Why is this? Will mobile development also operate in this way?

For example, this icon with v certification on Weibo

Why not divide the UI into a batch of files but crop them when using them?
By the way, will the mobile terminal also operate like this in real development?

淡淡烟草味淡淡烟草味2696 days ago927

reply all(3)I'll reply

  • 大家讲道理

    大家讲道理2017-07-03 11:44:32

    The resource is small in size and large in quantity. If divided into a batch of files, a large number of http requests will be generated when the web page is loaded. The establishment of http requests requires device performance and network bandwidth.

    Rather than saying why it is not divided into batches of files, it is better to say that small files are integrated and released together in order to improve new capabilities.

    reply
    0
  • 给我你的怀抱

    给我你的怀抱2017-07-03 11:44:32

    You can search for keywords such as sprite pictures, sprite pictures, sprite pictures

    reply
    0
  • PHP中文网

    PHP中文网2017-07-03 11:44:32

    This is the CSS sprite effect.
    Principle: Merge small icons and background images into one image, and then use CSS background positioning to display the part of the image that needs to be displayed.
    Purpose: Reduce the time it takes to load web page images The number of requests to the server increases the loading speed of the page.
    Problem: When loading for the first time, the memory consumption is relatively large, and unnecessary pictures or icons will also be loaded into the memory.


    Sprite effects are generally not used on mobile phones.
    The reason is that mobile phone memory is not rich, and resources on mobile phones are usually loaded into the memory when they are used (lazy load), and using sprites will improve image maintenance The cost is that more css operations are needed to display the specified image when using images. At the same time, in iOS, using sprite images also increases the difficulty of adapting images to different mobile phones .

    reply
    0
  • Cancelreply