# Occasional 404 Errors on testing site for JS files
On the testing site, some of the JS files respond with a 404 error sometimes, and the pattern seems to be random, except that it usually happens in about 1 in 5 tries.
### Check script
This simple script checks if the particular file is failing:
```python=
import requests
url = "https://us-ed-testing.ckan.io/webassets/ed/7c99bdf8_dataset_org_suborg.js"
count = 20
for i in range(count):
response = requests.request("GET", url, headers={}, data={})
failed = False
if response.status_code != 200:
print("Request {}: fails with status code: {}".format(i+1, response.status_code))
failed = True
print("This JS file is broken and needs to be fixed")
break
else:
print("Check {} was successful".format(i+1))
if not failed:
print("This link has a 200 status code after {} checks".format(count))
```
Files that don't return always return a 200 status code after the specified `count` number of times are flagged as having issues.
## JS Files before fix
These are all the JS files in the `webassets.yml` file:
| Asset name | Original Compiled JS files | Status |
| ---------- | ------- | ------------------- |
| ed_mainjs | `js/uswds.js`<br>`js/particles.js`<br>`js/simplebar.js`<br>`js/main.js`<br>`js/select-tags.js`<br>`js/underscore.js`<br>`js/backbone.js`<br>`js/recline.js`<br>`js/ed-autocomplete.js`<br>`js/ed-image-upload.js`<br>`js/confirm-reject.js`<br>`js/bulk-confirm-reject.js`<br>`js/bulk-confirm.js`<br>`js/resource-urls.js`<br>`js/ed-resource-reorder.js` | Passes the check, no changes required |
| [datasetorg_js](#datasetorg_js) | `js/dataset-org-suborg.js` | Fails and needs to be moved to ed_main |
| [edshowcaseimg_js](#edshowcaseimg_js) | `js/ed-showcaseimg.js` | Fails and needs to be moved to main |
| confirmreject_js | `js/confirm-reject.js` | Already in ed_main |
| bulkconfirmreject_js | `js/bulk-confirm-reject.js` | Already in ed_main |
| bulkconfirm_js | `js/bulk-confirm.js` | Already in ed_main |
| [markall_resources_js](#markall_resources_js) | `js/mark-all-resources.js` | |
| [download_resources_js](#download_resources_js) | `js/download-resources.js` | |
| edinline_js | `js/ed-inline.js` | Passes the check, no changes required |
| main_js | `js/main.js` | Already in ed_main |
| move_sidebar_js | `js/move-sidebar.js` | Passes all checks, no changes required |
| [edcollection_select_js](#edcollection_select_js) | `js/ed-collection-selection.js` | Fails and needs to be moved to ed_main |
| [edcustom_input_js](#edcustom_input_js) | `js/ed-custom-input-type.js` | Fails and needs to be moved to ed_main |
| [resourcetype_control_js](#resourcetype_control_js) | `js/resource-type-control.js` | Fails and needs to be moved to ed_main |
| ed_autocomplete_js | `js/ed-autocomplete.js` | Alreaady in ed_main |
| backbone_js | `js/backbone.js` | Alreaady in ed_main |
| showsummary_js | `js/showsummary.js` | Passes all checks, no changes required |
| [package_reorder_js](#package_reorder_js) | `js/package-reorder.js` | Fails and needs to be moved to ed_main |
| edreturn_to_search_js | `js/ed-return-to-search.js` | Passes all checks, no changes required |
| [ed_change_pkg_ownership_js](#ed_change_pkg_ownership_js) | `js/ed-change-package-owner.js` | Fails and needs to be moved to ed_main |
| hierarchy_js | `hierarchy/jquery.hierarchy.js` | Passes all checks, no changes required |
| ed_change_group_ownership_js | `js/ed-group-bulk-change-owner.js` | Passes all checks, no changes required |
### datasetorg_js
Left as is. It is supposed to make some changes to a `field-suborganizations` field, but it doesn't seem like that is being used anymore.
### edshowcaseimg_js
This adds a `background-image` style to each item of the pages items to generate the image show for each of the pages item.

**Usage**
This was previously called in:
* [Package showcase_item.html](https://github.com/CivicActions/ckanext-ed/blob/45f74f7f39aa121e1b05710ee51e50e213813114/ckanext/ed/templates/package/snippets/showcase_item.html#L40)
* [Documentation showcase_item.html](https://github.com/CivicActions/ckanext-ed/blob/45f74f7f39aa121e1b05710ee51e50e213813114/ckanext/ed/templates/documentation/snippets/showcase_item.html#L40)
This has been moved to `ed_mainjs` and still works fine.
> Required little code change
### markall_resources_js
### download_resources_js
### edcollection_select_js
This adds the interface for selecting collections in the data profile edit page.

**Usage**
This was previously called in:
* [Collection snippet for Dataset edit page](https://github.com/CivicActions/ckanext-ed/blob/45f74f7f39aa121e1b05710ee51e50e213813114/ckanext/ed/templates/package/snippets/field_collection_modal.html#L43)
> This has been moved to the `ed_mainjs`
> Required little code change
### edcustom_input_js
This customizes some of the fields in the dataset edit page.
**Usage**
This was previously called in:
* [Dataset edit page](https://github.com/CivicActions/ckanext-ed/blob/45f74f7f39aa121e1b05710ee51e50e213813114/ckanext/ed/templates/package/snippets/package_basic_fields.html#L438)
> Moved to ed_mainjs
### resourcetype_control_js
Changes the file upload field type in the resource form page
**Usage**
This was previously called in:
* [Resource Edit page](https://github.com/CivicActions/ckanext-ed/blob/45f74f7f39aa121e1b05710ee51e50e213813114/ckanext/ed/templates/package/snippets/resource_form.html#L186)
> Moved to ed_mainjs
### package_reorder_js
This is still being fixed: current error:
```
Throws TypeError: "sortable" is not a function when added to ed main.js
```
### ed_change_pkg_ownership_js
Handles package ownership change in the organization page
**Usage**
This was previously called in:
* [Organization Read page](https://github.com/CivicActions/ckanext-ed/blob/45f74f7f39aa121e1b05710ee51e50e213813114/ckanext/ed/templates/organization/read.html#L97)
> Moved to ed_mainjs
## JS files after fix
| Asset name | Original Compiled JS files | Status |
| ---------- | ------- | ------------------- |
| ed_mainjs | `js/uswds.js`<br>`js/particles.js`<br>`js/simplebar.js`<br>`js/main.js`<br>`js/select-tags.js`<br>`js/underscore.js`<br>`js/backbone.js`<br>`js/recline.js`<br>`js/ed-autocomplete.js`<br>`js/ed-image-upload.js`<br>`js/confirm-reject.js`<br>`js/bulk-confirm-reject.js`<br>`js/bulk-confirm.js`<br>`js/resource-urls.js`<br>`js/ed-resource-reorder.js` | Passes the check, no changes required |
| [datasetorg_js](#datasetorg_js) | `js/dataset-org-suborg.js` | Not sure what this does, left as is |
| [edshowcaseimg_js](#edshowcaseimg_js) | `js/ed-showcaseimg.js` | Moved to ed_mainjs |
| confirmreject_js | `js/confirm-reject.js` | Already in ed_main |
| bulkconfirmreject_js | `js/bulk-confirm-reject.js` | Already in ed_main |
| bulkconfirm_js | `js/bulk-confirm.js` | Already in ed_main |
| [markall_resources_js](#markall_resources_js) | `js/mark-all-resources.js` | Not sure what this does, left as is |
| [download_resources_js](#download_resources_js) | `js/download-resources.js` | Not sure what this does, left as is |
| edinline_js | `js/ed-inline.js` | Passes the check, no changes required |
| main_js | `js/main.js` | Already in ed_main |
| move_sidebar_js | `js/move-sidebar.js` | Passes all checks, no changes required |
| [edcollection_select_js](#edcollection_select_js) | `js/ed-collection-selection.js` | Moved to ed_mainjs |
| [edcustom_input_js](#edcustom_input_js) | `js/ed-custom-input-type.js` | Moved to ed_mainjs |
| [resourcetype_control_js](#resourcetype_control_js) | `js/resource-type-control.js` | Moved to ed_mainjs |
| ed_autocomplete_js | `js/ed-autocomplete.js` | Alreaady in ed_main |
| backbone_js | `js/backbone.js` | Alreaady in ed_main |
| showsummary_js | `js/showsummary.js` | Moved to ed_mainjs |
| [package_reorder_js](#package_reorder_js) | `js/package-reorder.js` | Fails and needs to be moved to ed_main |
| edreturn_to_search_js | `js/ed-return-to-search.js` | Passes all checks, no changes required |
| [ed_change_pkg_ownership_js](#ed_change_pkg_ownership_js) | `js/ed-change-package-owner.js` | Moved to ed_mainjs |
| hierarchy_js | `hierarchy/jquery.hierarchy.js` | Passes all checks, no changes required |
| ed_change_group_ownership_js | `js/ed-group-bulk-change-owner.js` | Passes all checks, no changes required |