반응형
wp_enqueue_script()를 사용하여 외부 스크립트를 큐잉해야 합니까?
그 함수로 외부 스크립트를 큐잉하는 것이 맞습니까?작동은 되는데 사이트 열기가 느려지지 않나요?
wp_register_script( 'google-maps', 'http://maps.googleapis.com/maps/api/js?sensor=true', null, null, true );
wp_register_script( 'jsapi', 'https://www.google.com/jsapi', null, null, true );
wp_register_script( 'bootstrap', 'https://maxcdn.bootstrapcdn.com/bootstrap/3.3.5/js/bootstrap.min.js', null, null, true );
wp_register_script( 'unveil', get_template_directory_uri() . '/new-js/jquery.unveil.min.js', null, null, true );
아니요, 사이트 속도가 느려지지 않습니다(적어도 사용하지 않는 이유가 될 정도는 아닙니다).이것은 WordPress에서 모든 유형의 스크립트를 큐잉하는 올바른 방법입니다.이 함수가 하는 모든 것은 적절한 것을 추가하는 것이다.<link>HTML에 태그(의존관계 포함)<head>.
그러나 어떤 이유로 인해 코드에 종속성이 포함되어 있지 않습니다.예를 들어 부트스트랩에는 jQuery가 필요하므로 함수에 포함해야 합니다.
wp_enqueue_script( 'bootstrap', 'https://maxcdn.bootstrapcdn.com/bootstrap/3.3.5/js/bootstrap.min.js', array('jquery'), '3.3.5', true );
위와 같이 다음 명령어를 사용하는 것도 고려해야 합니다.wp_register_script()한 발짝도 덜 수 있으니까.
언급URL : https://stackoverflow.com/questions/35224806/should-i-enqueue-external-scripts-using-wp-enqueue-script
반응형
'programing' 카테고리의 다른 글
| 외부 키는 NULL 또는 중복할 수 있습니까? (0) | 2023.04.05 |
|---|---|
| Mongo에서는 .find()가 .findOne()처럼 보이도록 결과를 예쁘게 인쇄하려면 어떻게 해야 합니까? (0) | 2023.04.05 |
| 스프링 부츠를 사용한 플라이웨이 수리 (0) | 2023.04.05 |
| Stencil과 Respect 및 Angular는 어떻게 다릅니까? (0) | 2023.04.05 |
| 반응 대 각도:React를 통한 느린 렌더링 (0) | 2023.04.05 |