---
title: "how to decide if the external js is loaded"
author: "Intrepid2012"
date: "2013-10-18T04:04:05Z"
tags: []
categories: ["Web前端"]
slug: "how-to-decide-if-the-external-js-is-loaded"
draft: false
lastmod: "2013-10-18T04:04:05Z"
id: 1960204
url: "https://intrepid2012.iteye.com/blog/1960204"
---

```
try to figure out if the external js lib is loaded:


<script language="javascript">
var len = $('script[src="<external JS>"]').length;
if (len === 0) {
    $.getScript('<external JS>');
}
</script>
```