The invention discloses a method and an electronic device for optimizing picture lazy loading by utilizing a front-end programming language. The method comprises the following steps: when a web page loads a cached picture through a picture lazy loading mode, judging whether a current node of the cached picture is rendered or not; when the cached picture is loaded through a picture lazy loading mode, judging whether the cached picture is rendered or not. When the current node rendering of the cached picture is completed, displaying a pre-defined cached picture in a web page; obtaining the target node of the target picture, and judging whether the target node satisfies the preset picture attribute information, and whether the target node completes the rendering; When the target node satisfies the picture attribute information and the target node has completed rendering, the target address of the target picture is obtained, the target picture is loaded according to the target address, thecached picture is replaced by the target picture, and the target picture is displayed. In this way, it is not necessary to monitor the operation of the user on the web page, and the performance of lazy loading of pictures is improved, thus the loading efficiency of pictures on the web page is improved, and time is saved.