광고 스크립트를 정적으로 로드하기
컬렉션을 사용해 정리하기
내 환경설정을 기준으로 콘텐츠를 저장하고 분류하세요.
개요
이 감사에서는 광고 스크립트가 페이지에 삽입되는지 여부를 확인합니다.
페이지의 다른 리소스는 삽입된
스크립트가 실행되면 광고 로드가 지연됩니다. 어떤 경우에는
스크립트를 전혀 가져올 수 없어 광고가
있습니다.
권장사항
비동기 스크립트 태그를 통해 스크립트를 로드하여 속도를 높입니다. 브라우저 미리 로드 스캐너
렌더링 차단 리소스가 차단되고 있더라도 스크립트 태그를 더 일찍 가져올 수 있음
스크립트 실행을 수정합니다.
올바르지 않음 |
<script>
var el = document.createElement('script');
el.src = 'https://securepubads.g.doubleclick.net/tag/js/gpt.js';
var node = document.getElementsByTagName('script')[0];
node.parentNode.insertBefore(el, node);
</script>
|
올바름 |
<script async src="https://securepubads.g.doubleclick.net/tag/js/gpt.js"></script>
|
삽입된 광고 스크립트의 소스 확인하기
때로는 광고 스크립트가 페이지에 삽입되는 방식과
아예 분사되고 있다고 상상해 보세요. 예를 들어 소스 코드를
스크립트가 로드되면 삽입된 스크립트 태그가
정적으로 로드된 태그와 구분할 수 없는 것입니다.
이 경우 Chrome DevTools의 '네트워크' 탭을 사용하여 소스를 결정하세요.
광고 스크립트를
삽입할 수 있습니다
Control+Shift+J
또는 Command+Option+J
(Mac)를 눌러 DevTools를 엽니다.
- 네트워크 탭으로 이동합니다.
- 아직 표시되지 않으면 필터를 클릭합니다.
를 눌러 필터 표시줄을 열고
이 감사에서 신고한 스크립트의 이름을 텍스트 상자에 입력합니다.
- 표시되지 않은 경우 표 헤더를 마우스 오른쪽 버튼으로 클릭하고
네트워크 요청에 Initiator 열을 포함하는 Initiator(시작자)
폭포식 구조 테이블
- 페이지를 새로고침하여 네트워크 트래픽을 캡처합니다.

위의 스크린샷에서 볼 수 있듯이 '시작자' 열에는
정보를 제공해 주세요 소스 링크를 클릭하면
광고 스크립트 요청 실행을 담당하는 코드로 바로 이동하는 경우
소스 링크 위로 마우스를 가져가면 요청으로 이어지는 모든 호출을 확인할 수 있습니다.
이 감사는 안전한 것으로 알려진 광고 스크립트의 허용 목록에 대해 작동합니다.
정적으로 로드됩니다. 현재 목록은 다음과 같습니다.
라이브러리 |
스크립트 |
애드센스 |
pagead2.googlesyndication.com/pagead/js/adsbygoogle.js
|
Amazon 게시자 서비스 |
amazon-adsystem.com/aax2/apstag.js
|
Criteo 직접 입찰자 |
static.criteo.net/js/*/publishertag.js
|
Google 게시자 태그 |
googletagservices.com/tag/js/gpt.js
securepubads.g.doubleclick.net/tag/js/gpt.js
|
Index Exchange |
js-sec.indexww.com/ht/p/*.js
|
document.write()에 대한 개입
스크립트 삽입 '비동기 스크립트' 유해한 것으로 간주됨
비동기 스니펫 속도 향상
달리 명시되지 않는 한 이 페이지의 콘텐츠에는 Creative Commons Attribution 4.0 라이선스에 따라 라이선스가 부여되며, 코드 샘플에는 Apache 2.0 라이선스에 따라 라이선스가 부여됩니다. 자세한 내용은 Google Developers 사이트 정책을 참조하세요. 자바는 Oracle 및/또는 Oracle 계열사의 등록 상표입니다.
최종 업데이트: 2024-08-22(UTC)
[null,null,["최종 업데이트: 2024-08-22(UTC)"],[[["\u003cp\u003eThis audit identifies ad scripts injected into the page that may delay or prevent ad loading.\u003c/p\u003e\n"],["\u003cp\u003eUse async script tags to improve loading speed, enabling the browser to fetch scripts earlier.\u003c/p\u003e\n"],["\u003cp\u003eIf the source of an injected ad script is unclear, Chrome DevTools' Network tab can be used to identify it.\u003c/p\u003e\n"],["\u003cp\u003eA list of safe-to-load ad scripts is provided, including those from AdSense, Amazon, Criteo, Google Publisher Tag, and Index Exchange.\u003c/p\u003e\n"]]],["Ad scripts injected into a page can delay or prevent ad loading. To improve speed, load scripts using `async` script tags, allowing the browser to fetch them earlier. To identify injected scripts, use Chrome DevTools' Network tab: filter by the script name and enable the \"Initiator\" column to find the source. The document provides examples of correct and incorrect code for loading scripts and includes a list of ad scripts from AdSense, Amazon, Criteo, Google Publisher Tag, and Index Exchange.\n"],null,["# Load ad scripts statically\n\nOverview\n--------\n\nThis audits checks whether or not ad scripts are being injected into the page.\nOther resources on the page may delay the fetching and loading of injected\nscripts, which will in turn delay the loading of ads. In some situations these\nscripts may not be fetched at all, preventing ads from being loaded all\ntogether.\n\nRecommendations\n---------------\n\nLoad scripts via async script tags to improve speed. The browser preload scanner\ncan fetch script tags earlier, even if render blocking resources are blocking\nthe script execution.\n\n|---------------|-------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------|\n| **Incorrect** | ```html \u003cscript\u003e var el = document.createElement('script'); el.src = 'https://securepubads.g.doubleclick.net/tag/js/gpt.js'; var node = document.getElementsByTagName('script')[0]; node.parentNode.insertBefore(el, node); \u003c/script\u003e ``` |\n| **Correct** | ```html \u003cscript async src=\"https://securepubads.g.doubleclick.net/tag/js/gpt.js\"\u003e\u003c/script\u003e ``` |\n\n### Identify the source of injected ad scripts\n\nSometimes it may not be obvious how an ad script is being injected into a page,\nor even that it's being injected at all. For example, when examining the source\nof a page after it's loaded, a script tag that has been injected may appear\nindistinguishable from a tag that was loaded statically.\n\nIn these cases, use the Network tab in Chrome DevTools to determine the source\nof injected ad scripts.\n\n1. Open DevTools by pressing `Control+Shift+J` or `Command+Option+J` (Mac).\n2. Navigate to the **Network** tab.\n3. If not already visible, click **Filter** to open the filter bar and type the name of the script flagged by this audit into the text box.\n4. If not already visible, right-click on any table header and select **Initiator** to include the Initiator column in the network request waterfall table.\n5. Reload the page to capture network traffic.\n\nAs seen in the above screenshot, the initiator column will contain information\nabout the source of the script in question. You can click on the source link to\njump directly to the code responsible for issuing the ad script request, or\nhover over the source link to see all of the calls leading up to the request.\n\nMore information\n----------------\n\nThis audit operates against a allowlist of ad scripts which are known to be safe\nto load statically. The current list is:\n\n| Library | Script(s) |\n|---------------------------|--------------------------------------------------------------------------------------|\n| AdSense | `pagead2.googlesyndication.com/pagead/js/adsbygoogle.js` |\n| Amazon Publisher Services | `amazon-adsystem.com/aax2/apstag.js` |\n| Criteo Direct Bidder | `static.criteo.net/js/*/publishertag.js` |\n| Google Publisher Tag | `googletagservices.com/tag/js/gpt.js` `securepubads.g.doubleclick.net/tag/js/gpt.js` |\n| Index Exchange | `js-sec.indexww.com/ht/p/*.js` |\n\n[Intervening against document.write()](https://developers.google.com/web/updates/2016/08/removing-document-write) \n\n[Script-injected \"async scripts\" considered harmful](https://www.igvita.com/2014/05/20/script-injected-async-scripts-considered-harmful/) \n\n[Speeding Up Async Snippets](https://csswizardry.com/2022/10/speeding-up-async-snippets/) \n[View audit source](https://github.com/googleads/publisher-ads-lighthouse-plugin/tree/HEAD/lighthouse-plugin-publisher-ads/audits/script-injected-tags.js) [Improve this article](https://github.com/googleads/publisher-ads-lighthouse-plugin/tree/HEAD/docs/audits/script-injected-tags.md) [Report an issue](https://github.com/googleads/publisher-ads-lighthouse-plugin/issues/new?labels=documentation&template=documentation-feedback.md&title=Documentation+feedback%3A+script-injected-tags.md)\n\n\u003cbr /\u003e"]]